package org.csu.mypetstore.service.impl;


import org.csu.mypetstore.domain.Account;
import org.csu.mypetstore.persistence.AccountMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AccountService {
    @Autowired
    private AccountMapper accountDAO;


    //获取所有用户信息
    public List<Account> getAllAccount(){
        return accountDAO.getallAccount();
    }

    //获取单一用户信息
    public Account getAccount(String username){
        return accountDAO.getAccountByUsername(username);
    }

    //更新用户信息
    public void updateAccount(Account account){
        accountDAO.updateAccount(account);
        accountDAO.updateSignon(account);
    }

    //搜索用户
    public List<Account> searchAccount(String keyword){
        return accountDAO.searchAccount("%" + keyword.toLowerCase() + "%");
    }
    //删除用户
    public void deleteaccount(String username){
        accountDAO.deleteAccount(username);
        accountDAO.deleteprofile(username);
        accountDAO.deleteSignon(username);
    }




}
